<html>
<head>
<h1>Login Page</h1>
</head>
<body>

<form action="userLogin.php" method="GET">
User ID: <input type='text' name = 'user' /> <br/>
Password: <input type='text' name = 'pwd' /> <br/>
<input type='submit' name = 'Login' value='Login'/>

</form>
</body>
<?php
//ABout the php file
//The script checks if given user ID is there is Database.
//Assumption:User ID and Password given by admin.Table already has a admin user account created by us.
//We can have UserID = to SSN or STudent Id/Faculty Id.Can be modifield later by adding a foreign key relation,to the table. 
//after correct login,it directs to MainMenu.php
	if(!isset($_GET["user"])) {
		return;
	}
	require "config.php";
	
	$userid = $_GET['user'];
	$pwd= $_GET['pwd'];
	
	$con = mysql_connect("localhost",$db_user ,$db_pass);
	if (!$con){
		die('Could not connect: ' . mysql_error());
    }
	mysql_select_db($db_name, $con);
	
	$query1 = "select * from user where (userId='$userid') AND (password = '$pwd')";
	$result1 = mysql_query($query1);
	if((mysql_num_rows($result1)==0)){
		echo "Incorrect UserId or Password.Please check credentials"	;
     }else {
		echo "correct user";?>
		<a href="MainMenu.php">Home</a>
		<?php
	}
	mysql_close($con);

?>

